#include "ddarray.h"
#include <crtdbg.h>
#define _CRTDBG_MAP_ALLOC

void fill_ar (DDArray * ar, Pointer value)
{
	size_t i, j;
	int *c;
	for (j=0; j<ar->Y; j++)
	{
		for(i=0; i<ar->X; i++)
		{
			c = (int*)find_element(ar, i, j);
			*c = value;
		}
	}
}

void print_ar ( DDArray * ar)
{
	size_t i, j;
	for(j=0; j<ar->Y; j++)
	{
		for (i=0; i<ar->X; i++)
		{
            printf("%d ", *(int*)find_element(ar, i, j));
		}
		printf("\n");
	}
}

int main () {
	DDArray *a;
	DDArray *b;
	int c=1;
	int i, j;

	a = new(&_DDArray, 8, 8, sizeof(int));

	fill_ar( a, c);
	print_ar( a );
    printf("\n");

	b = new(&_DDArray, 3, 3,  sizeof(int));
	c=3;
	fill_ar( b, c);
	copy(a, b, 0, 0);
	print_ar (a);
	printf("\n");

	resize(2, 2, a);
	print_ar(a);

	delete (a);
	delete (b);


	_CrtDumpMemoryLeaks();
	system("pause");
	return 0;
}